// src/entities/service-node.entity.ts
import { Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm';
import { ServiceEdge } from './service-edge.entity';

@Entity('service_nodes')
export class ServiceNode {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ length: 50, unique: true })
  serviceName: string;

  @Column({ length: 100, nullable: true })
  description: string;

  @Column({ length: 20, default: 'green' })
  status: 'green' | 'yellow' | 'red';

  @Column({ type: 'int', default: 0 })
  qps: number;

  @Column({ type: 'decimal', precision: 6, scale: 2, default: 0 })
  avgResponseTime: number;

  @OneToMany(() => ServiceEdge, (edge) => edge.source)
  outgoingEdges: ServiceEdge[];

  @OneToMany(() => ServiceEdge, (edge) => edge.target)
  incomingEdges: ServiceEdge[];
}
